Co-Operative Strategy Zero

library(gdata)         #loaded data         
help(read.xls)                  
mydata = read.xls("StrategyZero.xls")  
mydata = read.table("StrategyZero.txt") 
read.delim("StrategyZero.txt")
Co.Operative.Strategy.0 <- read.csv("~/Desktop/Statistics/Co-Operative Strategy 0.csv", header=TRUE)
Co.Operative.Strategy.1 <- read.csv("~/Desktop/Statistics/Co-Operative Strategy 1.csv", header=TRUE)
Co.Operative.Strategy.2 <- read.csv("~/Desktop/Statistics/Co-Operative Strategy 2.csv", header=TRUE)
McKibben <- read.csv("~/Desktop/McKibben.csv", header=TRUE)
attach(StrategyZero) #attached data

class(Co.Operative.Strategy.1$lngdp)
Co.Operative.Strategy.1$lngdp <- as.numeric(Co.Operative.Strategy.1$lngdp)

Country <- V2    #renamed columns 
bargain <- V3
ibargain <- V4
cooperativestrategy <- V5
lagdv <- V6
lag0 <- V7
lag1 <- V8
lag2 <- V9
lag3 <- V10
agreementimportance <- V11
votingpower <- V12
foreignpolicy <- V13
newms <- V14
qmv <- V15
euro <- V16
publicity <- V17
presidency <- V18
lndgp <- V19
pillar1 <- V20
pillar2 <- V21
pillar3 <- V22
parlscrut <- V23
issuelinkagestructure <- V24

hist(votingpower) #normal but uneven
hist(lndgp) #skewed
hist(euro) #bimodal
hist(newms) #bimodal
hist(issuelinkagestructure) #normal
hist(agreementimportance) #skewed
hist(parlscrut) #skewed
hist(qmv) #bimodal
hist(publicity) #bimodal
hist(presidency) #skewed

cor(lndgp,foreignpolicy) #-0.1588864
cor(lndgp,euro) #0.1935055
cor(lndgp,newms) #-0.7923564
cor(lndgp,issuelinkagestructure) #0.2004806
cor(lndgp,agreementimportance) #0.01444775
cor(lndgp,parlscrut) #-0.2421169
cor(lndgp,qmv) #-0.1839456
cor(lndgp,publicity) #-0.04338242
cor(lndgp,presidency) #0.191732

cor(votingpower,foreignpolicy) #-0.06811578
cor(votingpower,euro) #0.3259673
cor(votingpower,newms) #-0.2473758
cor(votingpower,issuelinkagestructure) #-0.1717908
cor(votingpower,agreementimportance) #-0.005472935
cor(votingpower,parlscrut) #-0.3447444
cor(votingpower,qmv) #0.05034966
cor(votingpower,publicity) #0.1141872
cor(votingpower,presidency) #0.005408445

##################Co-Operative Strategy Zero####################

Country1 <- V2
bargain1 <- V3
ibargain1 <- V4
cooperativestrategy1 <- V5
lagdv1 <- V6
lag01 <- V7
lag11 <- V8
lag21 <- V9
lag31 <- V10
agreementimportance1 <- V11
votingpower1 <- V12
foreignpolicy1 <- V13
newms1 <- V14
qmv1 <- V15
euro1 <- V16
publicity1 <- V17
presidency1 <- V18
lndgp1 <- V19
pillar11 <- V20
pillar21 <- V21
pillar31 <- V22
parlscrut1 <- V23
issuelinkagestructure1 <- V24

hist(votingpower1) #normal but uneven
hist(lndgp1) #skewed
hist(euro1) #bimodal
hist(newms1) #bimodal
hist(issuelinkagestructure1) #normal
hist(agreementimportance1) #skewed
hist(parlscrut1) #skewed
hist(qmv1) #bimodal
hist(publicity1) #bimodal
hist(presidency1) #skewed

cor(lndgp,foreignpolicy) #-0.1588864
cor(lndgp,euro) #0.1935055
cor(lndgp,newms) #-0.7923564
cor(lndgp,issuelinkagestructure) #0.2004806
cor(lndgp,agreementimportance) #0.01444775
cor(lndgp,parlscrut) #-0.2421169
cor(lndgp,qmv) #-0.1839456
cor(lndgp,publicity) #-0.04338242
cor(lndgp,presidency) #0.191732

cor(votingpower,foreignpolicy) #-0.06811578
cor(votingpower,euro) #0.3259673
cor(votingpower,newms) #-0.2473758
cor(votingpower,issuelinkagestructure) #-0.1717908
cor(votingpower,agreementimportance) #-0.005472935
cor(votingpower,parlscrut) #-0.3447444
cor(votingpower,qmv) #0.05034966
cor(votingpower,publicity) #0.1141872
cor(votingpower,presidency) #0.005408445

library(MASS)

McKibben$dv <- as.factor(McKibben$dv)

res <- polr(dv ~ lngdp + foreignpolicy + euro + new_ms + issue_linkage_structure + agreement_importance + parl_scrut + qmv + publicity + presidency + lag_dv, 
            data=McKibben,
            method="logistic")
summary(res)

library(lmtest)
coeftest(res)

###Updated Efforts, As of 21/1/14

cumulative(link = "BrookeData", parallel = FALSE, reverse = FALSE,
           mv = FALSE, whitespace = FALSE)

install.packages("mlogit")
library(mlogit)

is.factor(BrookeData$foreignpolicy)
as.factor(BrookeData$foreignpolicy)

is.factor(BrookeData$euro)
as.factor(BrookeData$euro)

is.factor(BrookeData$new_ms)
as.factor(BrookeData$new_ms)

is.factor(BrookeData$agreement_importance)
as.factor(BrookeData$agreement_importance)

is.factor(BrookeData$voting_power)
as.factor(BrookeData$voting_power)

is.factor(BrookeData$foreignpolicy)
as.factor(BrookeData$foreignpolicy)

is.factor(BrookeData$qmv)
as.factor(BrookeData$qmv)

is.factor(BrookeData$publicity)
as.factor(BrookeData$publicity)

is.factor(BrookeData$presidency)
as.factor(BrookeData$presidency)

is.factor(BrookeData$lngdp)
as.factor(BrookeData$lngdp)

is.factor(BrookeData$foreignpolicy)
as.factor(BrookeData$foreignpolicy)

is.factor(BrookeData$parl_scrut)
as.factor(BrookeData$parl_scrut)

is.factor(BrookeData$issue_linkage_structure)
as.factor(BrookeData$issue_linkage_structure)

is.factor(BrookeData$dv)
as.factor(BrookeData$dv)

###Here is where I started to run into issues. I get an error message saying that it cannot find the function "mlogit.data"

BrookeData2 <- mlogit.data(BrookeData, choice = "dv", shape = "wide")

NewModel <- mlogit(outcome ~ predictors, data = dataFrame, reflevel = a number representing the baseline category for the outcome) )

test <- multinom(prog2 ~ ses + write, data = ml)

attach(BrookeData2)

Country1 <- V2
bargain1 <- V3
ibargain1 <- V4
cooperativestrategy1 <- V5
lagdv1 <- V6
lag01 <- V7
lag11 <- V8
lag21 <- V9
lag31 <- V10
agreementimportance1 <- V11
votingpower1 <- V12
foreignpolicy1 <- V13
newms1 <- V14
qmv1 <- V15
euro1 <- V16
publicity1 <- V17
presidency1 <- V18
lndgp1 <- V19
pillar11 <- V20
pillar21 <- V21
pillar31 <- V22
parlscrut1 <- V23
issuelinkagestructure1 <- V24

library("mlogit")
NewModel<-mlogit(Co.operative.Strategy ~ agreement_importance + voting_power + foreignpolicy + new_ms + qmv + euro + publicity + lngdp + parl_scrut + issue_linkage_structure, data = BrookeData)

BrookeData<-read.csv("/users/BrookeLonghurst/Desktop/BrookeData.csv")
str(BrookeData)

BrookeData$Co.operative.Strategy<-as.factor(BrookeData$Co.operative.Strategy)

library(nnet)
lr_multi <- multinom(Co.operative.Strategy ~ 
                       agreement_importance + foreignpolicy + new_ms + qmv + euro + publicity + lngdp + parl_scrut + issue_linkage_structure, 
                     data=BrookeData,
                     Hess=TRUE)
summary(lr_multi)

install.packages("VGAM")
library(VGAM)